import datetime

from elixir import *

metadata.bind = "sqlite:///database"
metadata.bind.echo = True

class User(Entity):
    nickname = Field(Unicode(16), required=True)
    email = Field(String(100), required=True)
    password = Field(String(400), required=True)
    join_date = Field(DateTime, default=datetime.datetime.now)
    bio = Field(Text)
    image = Field(Integer)
    #Relationships
    item = OneToMany("Item", inverse="author")
    like = ManyToMany("Item", inverse="like")
    followtag = ManyToMany("Tag", inverse="following")
    follow = ManyToMany("User", inverse="follow")
class String(Entity):
    subject = Field(Unicode(40), required=True)
    tag = ManyToMany('Tag')
class Tag(Entity):
    name = Field(Unicode(20), required=True)
    string = ManyToMany('String')
    following = ManyToMany('User')
class Item(Entity):
    content = Field(Text, required=True)
    author = ManyToOne('User', inverse="item", required=True)
    date = Field(DateTime, default=datetime.datetime.now)
    like = ManyToMany('User', inverse="like")
